$(function(){
	//加载科室下拉列表
	$.post(contextPath + "/Department/findAllDep.dhc").done(function(result){
		var depInfo = result.data;
		$("#depSelect").html('<option value="null">请选择科室...</option>');
		$.each(depInfo,function(i,n){
			$("#depSelect").append('<option value="'+n.depCode+'">'+n.depName+'</option>');
		});
	});
	getQuotaList();
	getQuotaGroupList();
});

//列出指标
function getQuotaList() {
	$.post(contextPath + "/Quotas/findAllQuotas.dhc").done(function(result){
		$("#quota").html('');
		$.each(result,function(i,n){
			
			$("#quota").append('<div class="progress" id="'+n.quotaCode+'" draggable="true" ondragstart="drag(event)" style="height:50px;margin:4px;cursor: move;">'
					+'<div class="progress-bar progress-bar-success" style="width:100%;">'
					+'<span style="line-height:50px;font-size:20px;">'+n.quotaDesc+'</span></div></div>');
		});
	});
}
function drag(ev){
	ev.dataTransfer.setData("Text",ev.target.id);
}

//列出指标组
function getQuotaGroupList() {
	$.post(contextPath + "/Quotas/findAllQuotas.dhc").done(function(result){
	
	});
	$.getJSON($WEB_ROOT_PATH+"/quotaOutput/quotaOutputCtrl.htm?BLHMI=quotaGroupList",function(list){
		$("#quotaGroup").html('');
//		alert(JSON.stringify(list));
		$.each(list.rows,function(i,n){
			if(n==''){
				$("#quotaGroup").html('暂无分组');
			}
			$("#quotaGroup").append('<div class="alert alert-info" style="margin:5px;padding:8px;font-size:15px;cursor: move;" id="group'
					+n.QUOTA_GROUP_CODE+'" draggable="true" ondragstart="drag(event)">'+n.QUOTA_GROUP_DESC
					+'<a class="pull-right" title="删除分组" onclick="deleteGroup(\''+n.QUOTA_GROUP_DESC+'\',\''+n.QUOTA_GROUP_CODE
					+'\')"><i class="glyphicon glyphicon-remove"></i></a></div>');
		});
	});
}